package com.difsonapps.android.marker.dialogs;

import org.w3c.dom.Text;

import com.difsonapps.android.marker.IRefresher;
import com.difsonapps.android.marker.R;
import com.difsonapps.android.marker.beans.Photo;
import com.difsonapps.android.marker.beans.Video;
import com.difsonapps.android.marker.util.MarkerUtil;

import android.app.Activity;
import android.app.Dialog;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;


public class ViewPhotoDialog extends Dialog{
	Activity activity;
	Photo photo;
	IRefresher<Photo> refresher;
	Video video;
	IRefresher<Video> videoRefresher;
	
	
	TextView nameTextView;
	TextView createdTextView;
	TextView updatedTextView;
	TextView descriptionTextView;
	
	public ViewPhotoDialog(Activity activity, Photo photo, IRefresher<Photo> refresher) {
		super(activity);
		this.activity = activity;
		setTitle(R.string.photo_details);
		this.photo = photo;
		this.refresher = refresher;
		
		setContentView(R.layout.dialog_view_photo);
		nameTextView = (TextView)findViewById(R.id.name_text);
		createdTextView = (TextView)findViewById(R.id.created_text);
		updatedTextView = (TextView)findViewById(R.id.updated_text);
		descriptionTextView = (TextView)findViewById(R.id.description_text);
		findViewById(R.id.cancel_button).setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				cancelAction();
			}
		});
		
		if(photo!=null){
			nameTextView.setText(photo.getTitle());
			descriptionTextView.setText(photo.getDescription());
			createdTextView.setText(MarkerUtil.formatDateFromDefaultFormat(photo.getCreated_at()));
			updatedTextView.setText(MarkerUtil.formatDateFromDefaultFormat(photo.getModified_at()));
		}
	}
	
	public ViewPhotoDialog(Activity activity, Video video, IRefresher<Video> videoRefresher) {
		super(activity);
		this.activity = activity;
		setTitle(R.string.video_details);
		this.video = video;
		this.videoRefresher = videoRefresher;
		
		setContentView(R.layout.dialog_view_photo);
		nameTextView = (TextView)findViewById(R.id.name_text);
		createdTextView = (TextView)findViewById(R.id.created_text);
		updatedTextView = (TextView)findViewById(R.id.updated_text);
		descriptionTextView = (TextView)findViewById(R.id.description_text);
		findViewById(R.id.cancel_button).setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				cancelAction();
			}
		});
		
		if(video!=null){
			nameTextView.setText(video.getName());
			descriptionTextView.setText(video.getDescription());
			createdTextView.setText(MarkerUtil.formatDateFromDefaultFormat(video.getCreatedAt()));
			updatedTextView.setText(MarkerUtil.formatDateFromDefaultFormat(video.getModifiedAt()));
		}
	}
	
	private void cancelAction(){
		dismiss();
	}

}
